package ink.ykb.demo.permission.dao;
import java.util.List;

import org.beetl.sql.core.annotatoin.Sql;
import org.beetl.sql.core.mapper.BaseMapper;

import ink.ykb.demo.permission.entity.RoleRule;

public interface RoleRuleDao extends BaseMapper<RoleRule> {

  /**
   * 根据角色ID和权限ID获取关联配置
   * @param roleId
   * @param ruleId
   * @return
   */
	@Sql("select * from role_rule where role_id = ? and rule_id = ?")
  RoleRule getRoleRule(Long roleId,Long ruleId);
  
  /**
   * 根据角色ID和权限ID获取关联配置(加锁)
   * @param roleId
   * @param ruleId
   * @return
   */
  @Sql("select * from role_rule where role_id = ? and rule_id = ? for update")
  RoleRule getRoleRuleAndLock(Long roleId,Long ruleId);
  
  /**
   * 根据主键查询关联配置
   * @param id
   * @return
   */
  @Sql("select * from role_rule where id = ?")
  RoleRule getRoleRule(Long id);
  
  /**
   * 查询角色的所有权限配置
   * @param roleId
   * @return
   */
  @Sql("select * from role_rule where role_id = ?")
  List<RoleRule> getRoleRuleByRoleId(Long roleId);
  
  /**
   * 查询权限的所有权限配置
   * @param ruleId
   * @return
   */
  @Sql("select * from role_rule where rule_id = ?")
  List<RoleRule> getRoleRuleByRuleId(Long ruleId);
	
}